<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<PF:basePath/>">
		<title>流程实例</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<jsp:include page="/WEB-FACE/conf/includeH.jsp"></jsp:include>
	</head>
	<body class="easyui-layout">
		<div data-options="region:'north',border:false">
			<form id="dom_searchactruexecution">
				<table class="editTable">
					<tr>
						<td class="title">
							流程名称:
						</td>
						<td>
							<input name="b.NAME_:like" type="text">
						</td>
						<td class="title">
							任务名称:
						</td>
						<td>
							<input name="c.NAME_:like" type="text">
						</td>
						<td class="title">
							活动状态:
						</td>
						<td>
							<select name="a.IS_ACTIVE_:like">
								<option value="">
								</option>
								<option value="1">
									激活
								</option>
								<option value="0">
									挂起
								</option>
							</select>
						</td>
					</tr>
					<tr style="text-align: center;">
						<td colspan="6">
							<a id="a_search" href="javascript:void(0)"
								class="easyui-linkbutton" iconCls="icon-search">查询</a>
							<a id="a_reset" href="javascript:void(0)"
								class="easyui-linkbutton" iconCls="icon-reload">清除条件</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dom_datagridactruexecution">
				<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th field="PROCDEFNAME" data-options="sortable:true" width="80">
							流程名称
						</th>
						<th field="PROCDEFID" data-options="sortable:true" width="80">
							流程ID
						</th>
						<th field="PROCDEFKEY" data-options="sortable:true" width="80">
							流程KEY
						</th>
						<th field="VERSION" data-options="sortable:true" width="80">
							流程版本
						</th>
						<th field="TASKNAME" data-options="sortable:true" width="80">
							当前任务名称
						</th>
						<th field="TASKID" data-options="sortable:true" width="80">
							当前任务ID
						</th>
						<th field="TITLE" data-options="sortable:false" width="80">
							任务主题
						</th>
						<th field="ASSIGNEE" data-options="sortable:true" width="80">
							当前任务处理人
						</th>
						<th field="ACTIVE" data-options="sortable:true" width="80">
							活动状态
						</th>
						<th field="STARTTIME" data-options="sortable:true" width="80">
							流程启动时间
						</th>
					</tr>
				</thead>
			</table>
		</div>
	</body>
	<script type="text/javascript">
	var url_delActionactruexecution = "admin/ActRuExecutiondeleteCommit.do";//删除URL
	var url_formActionactruexecution = "admin/ActRuExecutionshow.do";//增加、修改、查看URL
	var url_searchActionactruexecution = "admin/ActRuExecutionqueryAll.do";//查询URL
	var title_windowactruexecution = "流程实例";//功能名称
	var gridactruexecution;//数据表格对象
	var searchactruexecution;//条件查询组件对象
	var TOOL_BARactruexecution = [ {
		id : 'view',
		text : '查看实例流程图',
		iconCls : 'icon-tip',
		handler : viewExecutImg
	}, {
		id : 'add',
		text : '激活',
		iconCls : 'icon-control-play',
		handler : runPlayProc
	}, {
		id : 'add',
		text : '挂起',
		iconCls : 'icon-control-stop',
		handler : runStopProc
	}, {
		id : 'edit',
		text : '流程参与者',
		iconCls : 'icon-group_green_edit',
		handler : editIdentityLinks
	}, {
		id : 'setAssignee',
		text : '指定任务执行人',
		iconCls : 'icon-user',
		handler : setAssignees
	}, {
		id : 'edit',
		text : '管理变量',
		iconCls : 'icon-library',
		handler : editVariable
	}, {
		id : 'del',
		text : '删除',
		iconCls : 'icon-remove',
		handler : delDataactruexecution
	} ];
	$(function() {
		//初始化数据表格
		gridactruexecution = $('#dom_datagridactruexecution').datagrid( {
			url : url_searchActionactruexecution,
			fit : true,
			fitColumns : true,
			'toolbar' : TOOL_BARactruexecution,
			pagination : true,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			ctrlSelect : true
		});
		//初始化条件查询
		searchactruexecution = $('#dom_searchactruexecution').searchForm( {
			gridObj : gridactruexecution
		});
	});

	//维护参与者
	function editIdentityLinks() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = "admin/ActRuExecution_ACTION_IDIDENTY.do"
					+ '?pageset.pageType=' + PAGETYPE.EDIT + '&ids='
					+ selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winactruexecution',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '管理参与者'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//指定任务执行人
	function setAssignees() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length == 1) {
			// 有数据执行操作
			$.messager.prompt('指定任务执行人', '请输入用户ID', function(r){
				if (r){
					$.messager.confirm(MESSAGE_PLAT.PROMPT,"是否指定该用户执行任务？", function(flag) {
						if (flag) {
							$.post('admin/ActRuTaskSetAssignee.do' + '?ids='
									+ selectedArray[0].TASKID, {id:r},
									function(flag) {
										if (flag.pageset.commitType == 0) {
											$(gridactruexecution).datagrid('reload');
										} else {
											var str = MESSAGE_PLAT.ERROR_SUBMIT
													+ flag.pageset.message;
											$.messager.alert(MESSAGE_PLAT.ERROR, str,
													'error');
										}
									});
						}
					});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}

	//维护参与者
	function editVariable() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = "admin/ActRuExecution_ACTION_Varyble.do"
					+ '?pageset.pageType=' + PAGETYPE.EDIT + '&ids='
					+ selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winactruexecution',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '管理参与者'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}

	//查看流程图
	function viewExecutImg() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionactruexecution + '?pageset.pageType='
					+ PAGETYPE.VIEW + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winactruexecution',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '浏览'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//新增
	function addDataactruexecution() {
		var url = url_formActionactruexecution + '?pageset.pageType='
				+ PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winactruexecution',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改
	function editDataactruexecution() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length > 0) {
			var url = url_formActionactruexecution + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID;
			;
			$.farm.openWindow( {
				id : 'winactruexecution',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}

	//激活实例
	function runPlayProc() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + "个实例将被激活，是否继续?";
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridactruexecution).datagrid('loading');
					$.post("admin/ActRuExecutionPlayCommit.do" + '?ids='
							+ $.farm.getCheckedIds(gridactruexecution), {},
							function(flag) {
								$(gridactruexecution).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridactruexecution).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//挂起实例
	function runStopProc() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + "个实例将被挂起，是否继续?";
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridactruexecution).datagrid('loading');
					$.post("admin/ActRuExecutiondStopCommit.do" + '?ids='
							+ $.farm.getCheckedIds(gridactruexecution), {},
							function(flag) {
								$(gridactruexecution).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridactruexecution).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//删除
	function delDataactruexecution() {
		var selectedArray = $(gridactruexecution).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$.post(url_delActionactruexecution + '?ids='
							+ $.farm.getCheckedIds(gridactruexecution), {},
							function(flag) {
								if (flag.pageset.commitType == 0) {
									$(gridactruexecution).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
</script>
</html>




